package cn.xinfei.xdecision.common.model.datax.exception;

public class XDecisionDataException extends RuntimeException {
    public XDecisionDataExceptionType exceptionType;
    public String detail;

    public XDecisionDataException(XDecisionDataExceptionType xyfCreditExceptionType, String message, Object... args) {
        super(message);
        initException(xyfCreditExceptionType, String.format(xyfCreditExceptionType.template, args));
    }

    public XDecisionDataException(XDecisionDataExceptionType xyfCreditExceptionType, String message, String detail) {
        super(message);
        initException(xyfCreditExceptionType, detail);
    }

    public XDecisionDataException(XDecisionDataExceptionType xyfCreditExceptionType, String detail) {
        super(detail);
        initException(xyfCreditExceptionType, detail);
    }

    public XDecisionDataException(XDecisionDataExceptionType xyfCreditExceptionType, String detail, Throwable cause) {
        super(detail, cause);
        initException(xyfCreditExceptionType, detail);
    }

    public XDecisionDataException(XDecisionDataExceptionType xyfCreditExceptionType, Throwable cause) {
        super(cause);
        initException(xyfCreditExceptionType);
    }

    public XDecisionDataException(XDecisionDataExceptionType xyfCreditExceptionType) {
        initException(xyfCreditExceptionType);
    }

    private void initException(XDecisionDataExceptionType exceptionType) {
        initException(exceptionType, exceptionType.text);
    }

    private void initException(XDecisionDataExceptionType exceptionType, String detail) {
        this.exceptionType = exceptionType;
        this.detail = detail;
    }
}
